<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="../lib/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../css/document/gth-recycler.css">
    <script type="text/javascript" src="../js/jquery-3.6.0.js"></script>
    <script src="../layer-v3.5.1/layer-v3.5.1/layer/layer.js"></script>
    <script type="text/javascript" src="../js/document/gth-recycler.js"></script>
    <title>Document</title>
    <style>
        table tr th {
            border: 1px solid #e6e6e6;
            background-color: white
        }

        table tr td {
            border: 1px solid #e6e6e6;
            background-color: white
        }
    </style>
</head>
<body onchange="location.reload();">


<table style="background-color: white ;height: 50px;margin: 12px auto;width: 98%">
    <tr>
        <td align="center">
            <h2>[ 文档回收站列表 ]</h2>
        </td>
    </tr>
</table>


<table border="0" class="layui_table" lay-even lay-skin="line" lay-size="lg"
       style="width: 98%; margin: 0px auto">

    <tr>

    </tr>

    <tr height="40">
        <th>序号</th>
        <th>名称</th>
        <th>类型</th>
        <th>所在部门</th>
        <th>删除时间</th>
        <th>操作</th>
    </tr>
    <tr style="height: 55px" th:each="re:${selrecall.list}">
        <td align="center"></td>
        <td align="center" th:text="${re.getTitle()}"></td>
        <td align="center" th:if="${re.getType()}==1"><img src="../images/document/jia2.png"></td>
        <td align="center" th:if="${re.getType()}==2"><img src="../images/document/doc.png"></td>
        <td align="center" th:if="${re.getType()}==3"><img src="../images/document/txt.png"></td>
        <td align="center" th:if="${re.getType()}==4"><img src="../images/document/jpg.png"></td>
        <td align="center" th:if="${re.getType()}==5"><img src="../images/document/pdf.png"></td>
        <td align="center" th:if="${re.getType()}==6"><img src="../images/document/xls.png"></td>
        <td align="center" th:if="${re.getType()}==7"><img src="../images/document/zip.png"></td>
        <td align="center" th:text="${re.getDepartment().getDepartmentname()}"></td>
        <td align="center" th:text="${#dates.format(re.getCreateDate(),'yyyy-MM-dd')}"></td>
        <td align="center" width="240"><input style="height: 30px;line-height: 30px;" type="button"
                                              class="layui-btn layui-btn-normal"
                                              th:onclick="'javascript:restore(\''+${re.getId()}+'\')'" value="还原">
            <input style="height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-danger"
                   th:onclick="'javascript:redel(\''+${re.getId()}+'\')'" value="删除"></td>
    </tr>
</table>
<div style="text-align: center; margin-top: 20px; margin-bottom: 20px">
    <a href="javascript:void(0)" type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-bg-green"
       onclick="start()">首页</a>
    <a type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-bg-green " href="javascript:void(0)"
       onclick="prev()">
        <i class="layui-icon layui-icon-left "></i></a>
    <a type="button" class="layui-btn layui-btn-sm layui-btn-primary ">
        <span><b class="yeshu">第1页 / 共1页</b></span></a>
    <a type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-bg-green" href="javascript:void(0)"
       onclick="next()">
        <i class="layui-icon layui-icon-right "></i>
    </a>
    <a href="javascript:void(0)" type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-bg-green"
       onclick="end()">尾页</a>
</div>
<inpput type="hidden" style="color: white;display: inline;" th:text="${selrecall.pages}" class="pages"></inpput>
<inpput type="hidden" style="color: white;display: inline;" th:text="${selrecall.pageNum}" class="PageNum"></inpput>
</body>
<script>
    var pages = $(".pages").text();
    var pageNum = $(".PageNum").text();
    console.log("总页数：------------------------" + pages)
    console.log("当前页：--------------------------" + pageNum)

    var currentPage = parseInt(pageNum);
    var pageSize = 5;
    var sumPage = parseInt(pages);
    if (sumPage == 0) {
        sumPage = 1;
    }

    $(".yeshu").text( "第" + currentPage + "页 / 共" + sumPage + "页" )
    function showPage() {
        location.href = "/document/sellrecycler?currentPage=" + currentPage + "&pageSize=" + pageSize
    }

    function next() {
        currentPage = currentPage + 1;
        console.log(currentPage + "----------currentPage")
        if (currentPage > sumPage) {
            currentPage = sumPage;
            layer.msg("最后一页啦")
            return;
        }
        showPage();
    }

    function prev() {
        currentPage = currentPage - 1;
        if (currentPage < 1) {
            currentPage = 1;
            layer.msg("前面没有啦")
            return;
        }
        showPage();
    }

    function end() {
        currentPage = sumPage
        showPage();

    }

    function start() {
        currentPage = 1
        showPage();

    }
</script>
</html>